package dao

import (
	"fmt"
	"github.com/astaxie/beego/orm"
	"learn-api/models"
	"time"
)

type UserDao struct {
}

//保存一条数据
func InsertUserData(userDataModel *models.UserDataModel) (err error, lastInsertId int64) {
	o := orm.NewOrm()
	var r orm.RawSeter
	r = o.Raw("INSERT INTO `learn`.`user_info` (`login_name`, `user_name`, `phone`, `create_time`) VALUES(?,?,?,?)", userDataModel.LoginName, userDataModel.UserName, userDataModel.Phone, time.Now())
	res, err := r.Exec()
	if err == nil {
		lastInsertId, _ = res.LastInsertId()
		fmt.Println("LastInsertId : ", lastInsertId)
	}

	return
}